<template>
  <div class="bg1">
    <img src="@/assets/lbg.jpg"
         class="lbg" />
    <div class="loginbg">
      <div class="login-center">
        <img src="@/assets/lbg01.png" class="lbg01" />
        <div style="display: flex;flex-direction: column;width: 100%;z-index: 19999;;">
          <span style="font-size: 35px; font-weight: 600; color: #2b64c2">巡视巡察数据填报系统</span>
          <div
            style="background-color: #FFFFFF; border-radius: 10px;margin-top: 50px;margin-left: 80px; margin-right: 80px; height: 50px;display: flex;flex-direction: row;align-items: center ">
            <img src="@/assets/psd.png" style="margin-left: 10px">
            <a-input-password class="psd-input" placeholder="请输入密码" v-model="password"
                              style="background-color: #FFFFFF; border: 0px;margin-right: 10px;margin-left: 5px">
            </a-input-password>
          </div>
          <div style="margin-top: 30px;margin-left: 80px; margin-right: 80px; ">
            <a-button type="primary" shape="round"
                      style="margin-top: 30px; width: 100%;height: 50px;font-size: 20px; border-radius: 10px"
                      class="login-submit"
                      @click="handleLogin"
            >
              <span v-if="!loading">登 录</span>
              <span v-show="false">登 录 中...</span>
            </a-button>
            <a @click="sm" v-show="false">tst</a>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { UserOutlined, InfoCircleOutlined } from '@ant-design/icons-vue';
import {
  getPassWord, testfile, testfile3, ttst,
} from '@/utils/JsonTools';
import fs from 'fs';
import { app } from 'electron';
import * as path from 'path';
import {decodeFile, decodeFile2, ecodeFile} from '@/utils/CodingsUtils';
import {getSystemDir} from "@/utils/common";

export default {
  name: 'Login',
  data() {
    return {
      password: '',
      loading: false,
    };
  },
  created() {
  },
  mounted() {
    this.test2();
  },
  methods: {
    ttst,
    testfile3,
    testfile,

    test2() {
      // let pathsys = fs.readFileSync('dbson/Back.dbson','utf-8')
      //   // const appPath = path.dirname(app.getPath('exe'))
      // console.log(pathsys)
      // // eslint-disable-next-line node/handle-callback-err
      // // fs.readFile('dbson/Filepath.dbson', 'utf8', function(err, dataStr) {
      // //   const filepath = dataStr.split('=')[1]
      // //   alert(filepath)
      // // })
      // document.getElementsByClassName('loginbg')[0].style.backgroundImage = `url('${pathsys}')`
    },
    handleLogin() {
      if (this.password === '') {
        this.$message.error('未输入密码');
        return false;
      }
      this.loading = true;
      let obj = {
        password: this.password,
      };
      getPassWord(obj).then(res => {
        // eslint-disable-next-line no-empty
        if (this.password.trim() === res.password) {
          this.$router.push({ path: '/application' }).catch(() => {
          });
          // eslint-disable-next-line no-empty
        } else {
          this.$message.error('密码错误');
          this.loading=false
        }
      });
    },
    async sm() {
      const ssd=fs.readFileSync("C:\\Users\\Administrator\\Desktop\\123344\\Readme.json","utf-8")
      const ssd2=fs.readFileSync("C:\\Users\\Administrator\\Desktop\\1024\\lanjian_supervision_work","utf-8")
      //const srt = "bbb0cac225f3d294f2954da53adec300a21d0ffa47254d93bb788152277e7ebcb4c79e050fbddb24fd750a512b02206224161ba69557fbbfabd2299d56502dbd84672b2e09dcd7a59c988faf532c54a93cf8c015486781dd01df99b8e2a3041cfa026e3f0b32"
      const sm = await decodeFile("cfc504747b3c9beb6f1152fe6fb59fe99011c619cf21f9ef97f00bb361c682d53424aced80d2b0897b918b18f37f62e970a9849336fdb70d2da466cbb0f7261a466179728849fb3c130e6ef14f14783797b8eb1e5786d3a855441cc650447aad1ca5649d24d468f940d6d4ea5fd8d31573d0b8b83cb9e1739f4569bb0a16d3c8bd483b6964352710f62a60576c14cbd9a271762bbd4d0a74cf0c023fe7c89faa2654ed63a467c3f0ad1c946b13c1434900eb7bdfa7d67c9649b249c27f0705b940d9969c1249e00d61d2a1ca90e1e82eea809e4d98aecf49a99112f9a1018d1052d84512a82b93ed9ab3b85e527246d0ddede6f4e79c952f04b0d81200bde62344c9eb50d59a1d4611899b553f80eaf2c2d144530e0e643a4d386a80910891b3062a7843765ac5e7361ec2ac092acfc569750a46e931bb377c431f57e9ae049ad6c7102afc172d5b3c61bb220f4268ea8225a3e3b9c3f6c6972a5ad1c299abde9d0236033bc15374318366f7159a");
      const sm2 = await decodeFile2(ssd2);
      console.log('sm-1-', sm);
      console.log('sm-2-', sm2);
    },
    async sm1() {
      const srt = "123456"
      const sm = await ecodeFile(srt);
      console.log('sm--', sm);
    }
  },
};
</script>
<style lang="scss" scoped>
.bg1 {
  position: absolute;
  width: 100%;
  height: 100%;
}

.loginbg {
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.lbg {
  background-size: 100% 100%;
  background-position: left;
  z-index: -999;
  position: fixed;
  left: 0;
  width: 100%;
  height: 100%;
}

.login-center {
  display: flex;
  margin: 0 auto;
  flex-direction: column;
  width: 650px;
  height: 420px;
  justify-content: center;
  align-items: center
}

.lbg01 {
  background-size: 100% 100%;
  background-position: center;
  z-index: -999;
  position: fixed;
  width: 860px;
  height: 700px;
}

//.loginbg{
//  background-image: url("../../imgs/lbg.jpg");
//}
//.login-center{
//  background-image: url("../../imgs/lbg01.jpg");
//  background-position:  center;
//  background-size: 98% 98%;
//}
::v-deep.ant-input-affix-wrapper .ant-input:not(:last-child) {
  border: none;
  outline: none;
}

::v-deepinput.ant-input:focus { /* 去除获取焦点时的样式 */
  border: none;
  box-shadow: none;
  outline: none;
}

::v-deepinput.ant-input.ant-input-lg {
  border: none;
  box-shadow: none;
  outline: none;
}

::v-deep.has-error .ant-input:focus {
  border: 1px solid #ffffff;
  box-shadow: none;
}

::v-deep.ant-input {
  border: 1px solid #ffffff;
}

::v-deep.ant-input-affix-wrapper .ant-input:focus {
  border: none;
  box-shadow: none;
  outline: none;
}

</style>
